﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using FangChanCrm.Services.Interface;
using Maticsoft.Model;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;

namespace FangChanCrm.Controllers
{
    public class PhoneYiJianFanKuiController : Controller
    {
        private readonly It_YiJianFanKuiBiaoService it_YiJianFanKuiBiaoService;
        public PhoneYiJianFanKuiController(It_YiJianFanKuiBiaoService YiJianFanKuiBiaoService)
        {
            it_YiJianFanKuiBiaoService = YiJianFanKuiBiaoService;
        }
        public IActionResult YiJianFanKuiAdd()
        {
            return View();
        }

        #region 添加
        public string Add()
        {
            t_YiJianFanKuiBiao t_YiJianFanKuiBiao = new t_YiJianFanKuiBiao();
            t_YiJianFanKuiBiao.RenYuanId = Convert.ToInt32(HttpContext.Session.GetString("UserId"));
            t_YiJianFanKuiBiao.FanKuiNeiRong = Request.Form["FanKui"];
            t_YiJianFanKuiBiao.YingDaNeiRong = "";
            t_YiJianFanKuiBiao.ZhuangTai = "未解决";
            t_YiJianFanKuiBiao.ShiJian = System.DateTime.Now.ToLongDateString()+DateTime.Now.ToLongTimeString().ToString();
            return ""+it_YiJianFanKuiBiaoService.Add(t_YiJianFanKuiBiao).Id;
        }
        #endregion

        #region 列表
        [HttpPost]
        public string GetListWithFenYe()
        {
            return JsonConvert.SerializeObject(it_YiJianFanKuiBiaoService.GetList(Convert.ToInt32(HttpContext.Session.GetString("UserId"))) , new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore });
        }
        #endregion
    }
}
